package com.ruoyi.hospital.controller.operation;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hospital.domain.operation.OperationCard;
import com.ruoyi.hospital.service.operation.IOperationCardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 首页卡片Controller
 * 
 * @author wendao
 * @date 2024-12-27
 */
@RestController
@RequestMapping("/hospital/operationCard")
public class OperationCardController extends BaseController
{
    @Autowired
    private IOperationCardService operationCardService;

    /**
     * 查询首页卡片列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:operationCard:list')")
    @GetMapping("/list")
    public TableDataInfo list(OperationCard operationCard)
    {
        startPage();
        List<OperationCard> list = operationCardService.selectOperationCardList(operationCard);
        return getDataTable(list);
    }

    /**
     * 导出首页卡片列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:operationCard:export')")
    @Log(title = "首页卡片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OperationCard operationCard)
    {
        List<OperationCard> list = operationCardService.selectOperationCardList(operationCard);
        ExcelUtil<OperationCard> util = new ExcelUtil<OperationCard>(OperationCard.class);
        util.exportExcel(response, list, "首页卡片数据");
    }

    /**
     * 获取首页卡片详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:operationCard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(operationCardService.selectOperationCardById(id));
    }

    /**
     * 新增首页卡片
     */
    @PreAuthorize("@ss.hasPermi('hospital:operationCard:add')")
    @Log(title = "首页卡片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OperationCard operationCard)
    {
        return toAjax(operationCardService.insertOperationCard(operationCard));
    }

    /**
     * 修改首页卡片
     */
    @PreAuthorize("@ss.hasPermi('hospital:operationCard:edit')")
    @Log(title = "首页卡片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OperationCard operationCard)
    {
        return toAjax(operationCardService.updateOperationCard(operationCard));
    }

    /**
     * 删除首页卡片
     */
    @PreAuthorize("@ss.hasPermi('hospital:operationCard:remove')")
    @Log(title = "首页卡片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(operationCardService.deleteOperationCardByIds(ids));
    }
}
